package com.yunji.cabinet.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.yunji.common.annotation.Excel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

@Data
public class CabinetScanVO {
    @ApiModelProperty("货柜ID")
    private Long containerId;

    @ApiModelProperty("货柜名称")
    private String containerName;

    @ApiModelProperty("芯片Imei")
    private String chipImei;

    @ApiModelProperty("芯片Sn")
    private String chipSn;

    @ApiModelProperty(value = "二维码Code")
    private String qrCode;

    @ApiModelProperty(value = "类型code")
    private String typeCode;

    @ApiModelProperty(value = "类型名称")
    private String typeName;

    @ApiModelProperty("网点ID")
    private Long siteId;

    @ApiModelProperty("网点名称")
    private String siteName;

    @ApiModelProperty("状态 0-离线 1-在线")
    private Integer onlineStatus;

    @ApiModelProperty("空柜数量")
    private Integer emptyQuantity;

    @ApiModelProperty("商品数量")
    private Integer productQuantity;

    public Integer getProductQuantity() {
        Integer quantity = 0;
        if (cells != null)
           for (CabinetCellVO cell : cells) {
            quantity+=cell.getProductQuantity();
          }
        return quantity;
    }

    @ApiModelProperty("商品上限")
    private Integer ceilingQuantity;

    public Integer getCeilingQuantity() {
        Integer quantity = 0;
        if (cells != null)
            for (CabinetCellVO cell : cells) {
                quantity+=cell.getCeilingQuantity();
            }
        return quantity;
    }

    public Integer getEmptyQuantity() {
        Integer quantity = 0;
        if (cells != null)
            for (CabinetCellVO cell : cells) {
                quantity+= (cell.getCeilingQuantity()-cell.getProductQuantity());
            }
        return quantity;
    }

    @ApiModelProperty("货柜格子信息")
    private List<CabinetCellVO> cells;

    @ApiModelProperty("点位ID")
    private Long locationId;

    @ApiModelProperty("点位名称")
    private String locationName;

    @ApiModelProperty("电量")
    private String coulomb;

    @ApiModelProperty("电压")
    private Integer volt;

    @ApiModelProperty("点位地址")
    private String locationAddress;

    @ApiModelProperty("货柜权限 0-无权限 1-有权限")
    @Excel(name = "货柜权限 0-无权限 1-有权限")
    private Integer accreditStatus;

    @ApiModelProperty("在线时间")
    private String onlineTime;

    @ApiModelProperty("离线时间")
    private String offlineTime;

    @ApiModelProperty("电量状态 1-正常 0-低电")
    private Integer battleStatus;

    @ApiModelProperty("电压变更时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date updateBattleTime;

    @ApiModelProperty("缺货状态 0-正常 1-缺货")
    private Integer lackStatus;

    @ApiModelProperty("缺货时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date lackTime;
}
